import java.util.Date;

/**
 * Basic example of throwing/catching custom Exceptions.
 * 
 * @author charlieg
 * @author <a href="mailto:charlieg@cis.udel.edu">charlieg@cis.udel.edu</a>
 * @author <a href="http://www.cis.udel.edu/~charlieg">www.cis.udel.edu/~charlieg</a>
 * @version 1.0, &nbsp; 1 Oct 2009
 *
 */
public class MilliDate {
	/**
	 * Takes positive int & returns Date equal to num milliseconds
	 * since "the epoch."
	 * 
	 * @param num int value for milliseconds
	 * @return Date equivalent to num milliseconds since "the epoch"
	 * @throws NegativeException if num is negative
	 */
	public static Date millisecondDate(int num) throws NegativeException {
		if (num < 0) {
			throw new NegativeException("number is negative!");
		} else {
			return new Date(num);
		}
	}
	
	public static void main(String[] args) {
		try {
			Date date = millisecondDate(987983607);
			System.out.println(date);
		} catch (NegativeException e) {
			System.out.println("Couldn't create Date, " + e);
		}
	}
}
